<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>抱抱堂-摇摇乐</title>
        <meta name="renderer" content="webkit">
        <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <meta name="format-detection" content="telephone=no">
		<script language="javascript">
		image = new Image();
		image.src = "{:C('IMG_PATH')}{$pageinfo.loding_pic}";
		image.src = "{:C('IMG_PATH')}static/img/layer_logo.png";
		function divboxs(){
		 var box=document.getElementById("boxs");
		 box.style.display="none";
		}
		setTimeout("divboxs()",3500);
		</script>
        <link rel="stylesheet" href="{:C('IMG_PATH')}static/css/main.css?v=12">
        <style>
			html,body {
			    margin:0;
			    padding:0;
			    overflow: hidden;
			}
			.logo .bg{ width:100%; height:auto; }
			.logo .baobaot{ width:5.109rem; height:5.109rem; position:absolute; top:2rem;text-align:center; left:50%;  margin-left:-2.554rem; }
			*{padding:0; margin:0;}
			.container {
			  left: 50%;
			  position: absolute;
			  top: 83%;
			  transform: translate(-50%, -50%);
			  -webkit-transform: translate(-50%, -50%);
			}

			/* PROGRESS */
			.progress {
			  background-color: #e5e9eb;
			  height: 0.1rem;
			  position: relative;
			  width: 6rem;
			  border-radius:0.3rem;
			}
			.progress-bar {
			  animation-duration: 3s;
			  animation-name: width;
			  background-image: linear-gradient(to right, #8c28da, #8c28da,#8c28da,#8c28da,#8c28da,#8c28da,#8c28da);
			  background-image: -webkit-linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);
			  height: 100%;
			  position: relative;
			}
			.progress-shadow {
			  height: 4rem;
			  position: absolute;
			  top: 100%;
			  transform-origin: 0 0;
			  width: 100%;
			}

			/* ANIMATIONS */
			@keyframes width {
			  0%, 100% {
			    transition-timing-function: cubic-bezier(1, 0, 0.65, 0.85);
			  }
			  0% {
			    width: 0;
			  }
			  100% {
			    width: 100%;
			  }
			}

		</style>
<script>
onload=function(){
    var fontS = document.documentElement.clientWidth*32/320;
    document.documentElement.style.fontSize=fontS+'px';
    window.onresize=function(){
        fontS = document.documentElement.clientWidth*32/320;
        document.documentElement.style.fontSize=fontS+'px';
    };
};
</script>
    </head>

    <body class="linear-bg"<notempty name="pageinfo.bg_pic"> style="background-image:url({$pageinfo.bg_pic})"</notempty>>
	<if condition="$pageinfo['loding_pic']">
		<div class="box" id="boxs" style="background:#373064;z-index: 999;width: 100%; height: 100%;">
			<div class="logo">
		    	<img src="{:C('IMG_PATH')}{$pageinfo.loding_pic}" class="bg"/>
		    	<img src="{:C('IMG_PATH')}static/img/layer_logo.png" class="baobaot"/>
		    </div>
		    <!-- 进度条代码 开始 -->
		    <div class="container">
		        <div class="progress">
		            <div class="progress-bar">
		            </div>
		        </div>
		    </div>
			<!-- 进度条代码 结束 -->
		</div>
	</if>
    <div class="remind" style="display:none;">
        <span>分享给好友，中奖概率翻翻翻~</span>
    </div>
    <header class="index">
        <section><img thissrc="{$user_info.avatar}"/></section>
        <section>
            <h4>{$user_info.nickname}</h4>
            <p  style="color:#FDD146;font-size:16px;">红包 {$money}元</p>
        </section>
        <section>
          	<!--<button class="yellow-btn" id="qiandao" >&nbsp;&nbsp;&nbsp;签到&nbsp;&nbsp;&nbsp;</button>
          	<button class="yellow-btn mygift" data-url="{:U('Portal/index/honghongbao')}">我的奖品</button>-->
          	<button class="yellow-btn mygift" data-url="{:U('Portal/index/honghongbao')}" style="float: right; margin-right: 15px;">我的奖品</button>
        </section>
    </header>
    <section class="index">
        <section class="yyl_hand"><img class="yyy_animation" thissrc="{:C('IMG_PATH')}static/img/yyl_main.png" /></section>
        <section class="yyl_intro"><img thissrc="{:C('IMG_PATH')}static/img/yyl_intro.png" /></section>
        <p class="yyl_rule">查看活动规则 <em></em></p>
    </section>
    <footer class="white"><img thissrc="{:C('IMG_PATH')}static/img/logo_white.png" /></footer>
    <div style="display:none" class="rule_content">{$pageinfo.event_intro}</div>
    <div class="main rule_gift_content" style="display:none;z-index:999;top:76px;">
        <section class="gift card">
            <h1>抱抱堂实物类奖品邮寄规则</h1>\
            <section style="margin:0 15px;">
              1. 声明<br />
              1.1 请您仔细阅读本规则并选择同意或不同意按本规则内容接受抱抱堂的实物奖品邮寄服务。若您经过中奖核实并确认要领取实物奖品，则自动视为您同意本规则内容。<br />
              1.2 请您自行负担因参与活动领取奖品而产生的税费(实物奖品可能需支付奖品金额的20%）<br />
              1.3 抱抱堂保留随时限制、中止、修改或替换奖品的权利。<br />
              <br />
              2. 定义<br />
              2.1 抱抱堂实物奖品：抱抱堂所提供的包括但不限于含密码或身份信息验证的卡券类、数码类、手机及配件类、电脑类、家电类、玩具类、饰品类、日用品类等需要通过邮寄或运输方式送达至用户的奖品。<br />
              <br />
              3. 邮寄<br />
              3.1 抱抱堂所提供的实物类奖品均以普通快递形式邮寄。除有特殊说明外，邮寄资费由抱抱堂承担。<br />
              补充说明：<br />
              3.1.1 若采用邮政普通包裹形式邮寄，请注意查收邮寄收据《包裹领取通知单》，到当地邮局领取奖品;<br />
              3.1.2 如遇节假日，奖品邮寄处理将顺延至工作日;<br />
              3.1.3 邮寄地区仅限中国大陆。<br />
              3.2 中奖后，工作人员会在规定时间内通过电话与您确认领取与邮寄信息，如因用户自身原因没有接听或者拒绝提供相应信息导致无法邮寄奖品，抱抱堂则视为用户放弃获奖资格，由此造成的损失由获奖用户承担。<br />
              3.3 奖品邮寄信息确认后不可变更。请务必正确告知收件人姓名、邮寄地址、邮编。<br />
              3.4 由于您的地址、电话等个人信息的变更，或者第三方的因素造成的送货不成功，抱抱堂将积极配合您查找原因并协调处理，但由此引起的后果及损失，抱抱堂一律不承担，兑换奖品将不予补寄，敬请留意!<br />
              3.5 “抱抱堂实物类奖品”交付时，获奖用户应当在签收后的三天内(如有明确签收时间的，以该签收时间后的72小时为三天;如签收时间仅有日期的，以该日后的第二天零时为起算时间，满72小时为三天)完成验收。 如果出现问题，请保留好相关凭证与抱抱堂取得联系。<br />
            </section>
            <section class="gift_btn">
                <button class="long-line-btn isee-btn">我知道了</button>
            </section>
        </section>
    </div>
    </body>
    <script src="{:C('IMG_PATH')}static/js/zepto.min.js"></script>
    <script src="http://zb.weixin.qq.com/nearbycgi/addcontact/BeaconAddContactJsBridge.js"></script>
    <!-- <script src="{C('IMG_PATH')}/static/js/wx.js"></script> -->
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script src="http://yyy.bbtpictures.com/static/zepto.min.js"></script>
    <script>
    (function(){
        var firstLogin = "{$first_visit}";
        var lastUpdate = 0;
        var shakeCount = 0;
        var x = 0;
        var y = 0;
        var z = 0;
        var lastX = 0;
        var lastY = 0;
        var lastZ = 0;
        var shake_status = 0; //0:正常；1：摇动；2：摇动结束，获取数据；3：展示结果可以继续摇奖；4：展示结果不可以继续摇奖；
        var messageDOM = false;
        var giftCount = 0;
        //
        if(window.DeviceMotionEvent){
            window.addEventListener("devicemotion", deviceMotionHandler, false);
        }else{
            alert('您的手机不支持在这里摇一摇，退出再摇吧');
        }
        $.fn.scrollTo =function(options){
            var defaults = {
                toT : 0,    //滚动目标位置
                durTime : 500,  //过渡动画时间
                delay : 30,     //定时器时间
                callback:null   //回调函数
            };
            var opts = $.extend(defaults,options),
                timer = null,
                _this = this,
                curTop = _this.scrollTop(),//滚动条当前的位置
                subTop = opts.toT - curTop,    //滚动条目标位置和当前位置的差值
                index = 0,
                dur = Math.round(opts.durTime / opts.delay),
                smoothScroll = function(t){
                    index++;
                    var per = Math.round(subTop/dur);
                    if(index >= dur){
                        _this.scrollTop(t);
                        window.clearInterval(timer);
                        if(opts.callback && typeof opts.callback == 'function'){
                            opts.callback();
                        }
                        return;
                    }else{
                        _this.scrollTop(curTop + index*per);
                    }
                };
            timer = window.setInterval(function(){
                smoothScroll(opts.toT);
            }, opts.delay);
            return _this;
        };

        $("#qiandao").on("click", function(){
			$.get("{:U('Portal/index/qiandao')}",function(data){
			    alert(data);
		  });
        });

        $(".mygift").on("click", function(e){
            window.location.href = $(e.target).data("url");
        });

        $(".yyl_rule").on("click", function(e){
            messageShow("rule", $('.rule_content').html());
        });
        $(".isee-btn").on("click", function(e){
            $('.rule_gift_content').hide();
        });

        function checkFollow(next){
    		//判断是否关注
    		BeaconAddContactJsBridge.invoke('checkAddContactStatus',{} ,function(apiResult){
    			if(apiResult.err_code == 0){
    				var status = apiResult.data;
    				if(status == 1){
    					next();
    				}else{
    					//跳转到关注页
                        messageHidden(function(){
                            messageShow("warning", "先关注公众号才能领取奖品哦~");
                            setTimeout(function(){
                                BeaconAddContactJsBridge.invoke('jumpAddContact');
                            }, 2000);
                        });
    				}
    			}else{
    				next();
    			}
    		});
        }

        function messageShow(kind, data) {
            var content = '';
            var myHongbao = "{:U('Portal/index/honghongbao')}";

            if (kind == 0) { //红包类型
                content = '\
                <h1>' + data.congratulations + '</h1>\
                <section class="gift_pic"><a href="' + (data.center_url ? data.center_url : '#') + '"><img src="' + (data.center_pic ? data.center_pic : "{:C('IMG_PATH')}static/img/big_hongbao.png") + '" /></a></section>\
                <section class="gift_btn">\
                    <div><p>' + data.money + ' <span>元</span></p></div>\
                    <p>已存入账户</p>\
                </section><div style="text-align: center;padding-bottom: 20px;">\
                    <button class="long-line-btn continue-btn">　继续摇奖　</button>\
                    //　或　\
                    //<a href="{:U('Portal/index/duobao')}"><button class="long-yellow-btn">　参与夺宝　</button></a>\
                    </div>';
                giftCount++;
            }
            if (kind == 1) { //中奖出错
                content = '\
                <h1>很可惜 这次没有中奖</h1>\
                <section class="gift_pic"><img src="{:C('IMG_PATH')}static/img/big_fail.png" /></section>\
                <section class="gift_btn">\
                    <button class="long-yellow-btn continue-btn">继续摇奖</button>\
                </section>';
                //展示分享提醒
                showShareRemind(1);
            }
            if (kind == 2) { //没中奖
                content = '\
                <h1>' + data.title + '</h1>\
                <section class="gift_pic"><a href="' + (data.center_url ? data.center_url : '#') + '"><img src="' + (data.center_pic ? data.center_pic : "{:C('IMG_PATH')}static/img/big_fail.png") + '" /></a></section>\
                <section class="gift_btn">\
                    <button class="long-yellow-btn continue-btn">继续摇奖</button>\
                </section>';
                //展示分享提醒
                showShareRemind(1);
            }
            if (kind == 3) { //红包已用完
                content = '\
                <h1>今天红包已经摇完</h1>\
                <section class="gift_pic"><img src="' + data.center_pic + '" /></section>\
                <section class="gift_btn">\
                    <button class="long-yellow-btn continue-btn">继续摇奖</button>\
                </section>';
                //展示分享提醒
                showShareRemind(1);
            }
            if (kind == 4) { //中链接类奖品
                content = '\
                <h1>' + data.title + '</h1>\
                <section class="gift_pic"><a href="' + (data.center_url ? data.center_url : '#') + '"><img src="' + data.center_pic + '" /></a></section>\
                <section class="gift_intro">\
                    <p>' + data.description + '</p>\
                </section>\
                <section class="gift_btn">\
                    <button class="long-line-btn continue-btn">继续摇奖</button>\
                    <button class="long-yellow-btn gotit-btn">我要领奖</button>\
                </section>';
                giftCount++;
            }
            if (kind == 5) { //中实体奖品
                content = '\
                <h1>' + data.title + '</h1>\
                <section class="gift_pic"><img src="' + data.center_pic + '" /></section>\
                <section class="gift_intro">\
                    <p>' + data.description + '</p>\
                </section>\
                <section class="gift_btn">\
                    <button class="long-line-btn continue-btn">继续摇奖</button>\
                    <button class="long-yellow-btn gotit-btn" data-code="' + data.card_code + '">我要领奖</button>\
                </section>';
                giftCount++;
            }
            if(kind == "profile") { //填写个人资料
                content = '\
                <h1>' + data.title + '</h1>\
                <section class="gift_pic"><img src="' + data.center_pic + '" /></section>\
                <section class="gift_intro">\
                    <p>' + data.description + '</p>\
                </section>\
                <section class="gift_personal_info">\
                    <form name="phone" method="post" class="form_profile">\
                        <input type="hidden" name="cid" value="' + data.cid + '" />\
                        <p><input type="text" name="real_name" placeholder="真实姓名" /></p>\
                        <p><input name="phone_number" type="number" placeholder="手机号" /></p>\
                        <p class="captcha_box"><input name="captcha_number" type="number" placeholder="短信验证码" /><button st="1" class="long-yellow-btn captcha">获取验证码</button></p>\
                        <p><textarea name="address" placeholder="邮寄地址"></textarea></p>\
                        <p style="display:none;"><input type="text" name="idcode" placeholder="身份证号" /></p>\
                        <section class="gift_btn">\
                            <button class="long-yellow-btn gotit-btn">立刻领取</button>\
                        </section>\
                        <section class="gift_agreement">\
                            <em class="select_box"></em> 并同意 <span class="gift_entity_rule">实物奖品邮寄规则 &gt;</span>\
                        </section>\
                        <section class="gift_btn">\
                            <button class="long-line-btn continue-btn">继续摇奖</button>\
                        </section>\
                    </form>\
                </section>';
            }
            if (kind == "rule") { //规则简介
                content = '\
                <h1>活动规则</h1>\
                <section class="gift_rule">' + data + '</section>\
                <section class="gift_btn">\
                    <button class="long-yellow-btn continue-btn">我知道了</button>\
                </section>';
            }
            if (kind == "warning") {
                content = '<h1>' + data + '</h1>';
            }

            var message = '<div class="main main_layer"><section class="gift card">' + content + '</section></div>';

            messageDOM = $(message);
            $(document.body).append(messageDOM);

            messageDOM.animate({
                opacity: 1,
                top:'76px'
            }, 200, 'ease-in', function(){
                shake_status = 3;

                if (kind == 0) {
                    $(".money_count").html((parseFloat($(".money_count").html()) + parseFloat(data.money)).toFixed(2));
                    shake_status = 4;
                }
                if (kind == 4) {
                    $(".gotit-btn").on("click", function(){
                        window.location.href = data.center_url;
                    });
                    shake_status = 4;
                }
                if (kind == 5) {
                    $(".gotit-btn").on("click", function(e){
                        var param = data;
                        param['cid'] = $(e.target).data("code");
                        verifyProcess(0, param);
                    });
                    shake_status = 4;
                }

                if (kind == "profile") {
                    var form = $(".form_profile");
                    form.submit(function(e){
                        e.preventDefault();
                    });

                    $(".captcha").on("click", function(e){
                        verifyProcess(1, form);
                    });
                    $(".gotit-btn").on("click", function(e){
                        verifyProcess(2, form);
                    });
                    $(".gift_entity_rule").on("click", function(e){
                        $('.rule_gift_content').show();
                    });
                    shake_status = 4;
                }

                $(".continue-btn").on("click", function(){
                    messageHidden(function() {
                        shake_status = 0;
                    });
                });
            });
        }

        var checkForm = {
            phoneNumber : function(pn) {
                if (pn.length == 11) {
                    return true;
                }
                return false;
            },
            captchaNumber : function(pn) {
                if (pn.length == 6) {
                    return true;
                }
                return false;
            },
            captchaTime : 1,
            captchaBtn : function(status, btn) {
                var time = 60;

                if (status == 0) {
                    clearTimeout(captchaTime);
                    btn.innerHTML = "获取手机验证码";
                    $(btn).attr("st", "1");
                    return;
                }

                var countDown = function() {
                    if (time > 0 && $(btn).attr("st") == 0) {
                        if (status == 1) {
                            btn.innerHTML = time + "秒剩余";
                        }
                        time--;
                        captchaTime = setTimeout(countDown, 1000);
                    } else {
                        checkForm.captchaBtn(0, btn);
                    }
                }

                $(btn).attr("st", "0");
                countDown();
            },
            realName : function(pn) {
                if (pn.length >= 2) {
                    return true;
                }
                return false;
            },
            address : function(pn) {
                if (pn.length >= 6) {
                    return true;
                }
                return false;
            },
            idcode : function(pn) {
                return true;
                if (pn.length >= 15) {
                    return true;
                }
                return false;
            }
        }

        function verifyProcess(step, data) {
            if (step == 0) { //验证是否具有领取资格
                if (data) {
                    $.ajax({
                        url : "{:U('Portal/api/getPrizes')}",
                        cache : false,
                        type : "POST",
                        dataType : "json",
                        data : {'cid' : data.cid},
                        success : function(msg, textStatus){
                            if (msg.errcode == 0) {
                                if (msg.data.status == 0) {
                                    alert('奖品领取成功，稍后会有客服与您联系');
                                    window.location.reload();
                                    return;
                                } else if (msg.data.status == 2){
                                    messageHidden(function(){
                                        messageShow("profile", data);
                                    });
                                    setTimeout(function(){
                                        $(document.body).scrollTo({toT:400});
                                    }, 500);
                                }
                            } else {
                                alert('奖品领取失败，请稍后重试');
                            }
                        },
                        error : function(){
                            alert('哇!, 奖品领取失败了。');
                        }
                    });
                }
            }

            if (step == 1) { //获取验证码
                if($($('.captcha')[0]).attr("st") == "0"){
                    return;
                }

                var form = data.serializeArray();
                // 验证手机号
                var phoneNumber = "";
                $(form).each(function(index) {
                    if (this.name == "phone_number") {
                        phoneNumber = this.value;
                        return;
                    }
                });

                if (checkForm.phoneNumber(phoneNumber)) {
                    checkForm.captchaBtn(1, $('.captcha')[0]);

                    $.ajax({
                        url : "{:U('Portal/api/getPhoneCaptcha')}",
                        cache : false,
                        type : "POST",
                        dataType : "json",
                        data : {
                            "phone_number" : phoneNumber
                        },
                        success : function(msg, textStatus){
                            if (msg.errcode == 0) {
                                if (msg.data.status == 0) {
                                    alert('验证码下发成功');
                                    return;
                                }
                                if (msg.data.status == 4) {
                                    alert('每天限制3条短信已经用完，有问题请联系客服');
                                    return;
                                }
                                alert('验证码下发失败，请重试');
                                checkForm.captchaBtn(0, $('.captcha')[0]);
                            } else {
                                alert('验证码下发失败，请重试');
                                checkForm.captchaBtn(0, $('.captcha')[0]);
                            }
                        },
                        error : function(){
                            alert('验证码下发失败，请重试');
                            checkForm.captchaBtn(0, $('.captcha')[0]);
                        }
                    });
                } else {
                    alert('手机号码格式错误，请再次输入');
                }
            }

            if (step == 2) {
                var phoneNumber = "";
                var captchaNumber = "";
                var realName = "";
                var address = "";
                var idcode = "";

                var form = data.serializeArray();
                $(form).each(function(index) {
                    if (this.name == "phone_number") {
                        phoneNumber = this.value;
                    }
                    if (this.name == "captcha_number") {
                        captchaNumber = this.value;
                    }
                    if (this.name == "real_name") {
                        realName = this.value;
                    }
                    if (this.name == "address") {
                        address = this.value;
                    }
                    if (this.name == "idcode") {
                        idcode = this.value;
                    }
                });

                if (checkForm.phoneNumber(phoneNumber) &&
                 checkForm.captchaNumber(captchaNumber) &&
                 checkForm.realName(realName) &&
                 checkForm.address(address) &&
                 checkForm.idcode(idcode) ) {
                    $.ajax({
                        url : "{:U('Portal/api/saveUserInfo')}",
                        cache : false,
                        type : "POST",
                        dataType : "json",
                        data : form,
                        success : function(msg, textStatus){
                            if (msg.errcode == 0) {
                                if (msg.data.status == 0) {
                                    alert("奖品领取成功，稍后客服会联系您");
                                    messageHidden();
                                    window.location.reload();
                                    return;
                                }
                                alert('个人信息提交失败，请稍后重新提交');
                            }
                        },
                        error : function(){
                            alert('个人信息提交失败，请稍后重新提交');
                        }
                    });
                } else {
                    alert("表单填写错误");
                }
            }
        }

        function messageHidden(func){
            if (messageDOM) {
                $(".continue-btn").off();
                $(".captcha").off();
                $(".gotit-btn").off();
                $(".gift_entity_rule").off();
                messageDOM.animate({
                    opacity: 0,
                    top:'100px'
                }, 'fast', 'ease-out', function(){
                    messageDOM.remove();
                    messageDOM = false;
                    shake_status = 0;
                    if (func) {
                        func();
                    }
                });
            } else {
                $(".main_layer").remove();
                shake_status = 0;
                if (func) {
                    func();
                }
            }
        }

        function deviceMotionHandler(eventData){
            //0:正常；1：摇动；2：摇动结束，获取数据；3：可以继续摇奖；4：展示结果不可以继续摇奖；
            if(shake_status == 2 || shake_status == 4){
                return;
            }

            shake_status = 1;

            var acceleration = eventData.accelerationIncludingGravity,
                currTime = new Date().valueOf(),
                diffTime = currTime - lastUpdate;

            if(diffTime > 50){
               lastUpdate = currTime;
               x = acceleration.x;
               y = acceleration.y;
               z = acceleration.z;
               var speed = Math.abs(x + y + z - lastX - lastY - lastZ) / diffTime * 10000;

               if(speed > 2000){
                     shakeCount++;
               } else {
                   shakeCount = 0;
               }
               lastX = x;
               lastY = y;
               lastZ = z;

               if (shakeCount > 2) {
                   //摇动结束
                    shake_status = 2;
                    shakeCount = 0;
                    if (giftCount == 1) {
                        checkFollow(function(){
                            messageHidden(getPrize);
                        });
                    } else {
                        messageHidden(getPrize);
                    }
               }
            }
        }

        function getPrize(){
            // 获取红包
            animation("start", function(){
                $.ajax({
                    url : "{:U('Portal/api/shake')}",
                    cache : false,
                    type : "POST",
                    dataType : "json",
                    data : {},
                    success : function(msg, textStatus){
                        if (msg.errcode == 0) {
                            // 中奖
                            messageHidden(function(){
                                messageShow(msg.data.status, msg.data.prizes);
                            });
                            // var d = {
                            //     title : "123",
                            //     center_pic : "http://ww2.sinaimg.cn/orj480/61e89b74jw1f4ycyamt2wj20hi0c6mz7.jpg",
                            //     description : "hello world",
                            //     card_code : 123
                            // }
                            // messageShow('5', d);
                            return;
                        } else if (msg.errcode == 504) {
                            window.location.href = msg.jumpUrl;
                        } else if (msg.errcode == 403) {
                            alert(msg.errmsg);
                        }
                    },
                    error : function(){
                        messageHidden();
                    }
                });
            });
        }

        <if condition="APP_ENV eq 'DEV' ">
            // 测试
            $(".yyy_animation").on("click", function(){
                shake_status = 2;
                getPrize();
            });
        </if>

        // 动画
        var animation_img = $($(".yyy_animation")[0]);
        var actionHandle = 0;
        var frameList = [
            'm00','m01','m02','m03','m04','m05','m06','m07','m08','m09','m10','m11','m12','m13',
            'm14','m15','m16','m17','m18','m19','m20','m21','m22','m23','m24','m25','m26','m27','m28'
        ];
        function animation(action, func){
            var picNumber = 0;
            if (action == "start") {
                if (actionHandle == 0) {
                    actionHandle = setInterval(function(){
                        if (picNumber >= frameList.length) {
                            picNumber = 0;
                            animation("stop", func);
                        }
                        animation_img.attr('src', '{:C('IMG_PATH')}static/img/' + frameList[picNumber] + '.png');
                        picNumber++;
                    }, 33);
                }
            }
            if (action == "stop") {
                clearTimeout(actionHandle);
                actionHandle = 0;
                setTimeout(function(){
                    animation_img.attr('src', '{:C('IMG_PATH')}static/img/yyl_main.png');
                }, 33);
                if (func) {
                    func();
                }
            }
        }

        //展示分享提醒
        function showShareRemind(show){
            var remind = $('.remind');
            var timer;
            var startT = -55;
            var endT = -5;

            var remindDown = function(){
                if(remind.css('display') == 'none'){
                    remind.show();
                    var startT2 = startT;
                    timer = setInterval(function(){
                        if (startT2 == endT){
                            clearInterval(timer);
                            return;
                        }
                        startT2++;
                        remind.css('top', startT2 + 'px');
                    }, 10);
                } else {
                    return;
                }
            };
            var remindUp = function(){
                var endT2 = endT;
                timer = setInterval(function(){
                    if (endT2 == startT){
                        clearInterval(timer);
                        remind.hide();
                        return;
                    }
                    endT2--;
                    remind.css('top', endT2 + 'px');
                }, 10);
            };

            if(show){
                remindDown();
                setTimeout(function () {
                    remindUp();
                }, 8000);
            } else {
                remindUp();
            }
        }

        $(function($) {
            if (firstLogin == '1') {
                shake_status = 2;
                shakeCount = 0;
                setTimeout(function(){
                    getPrize();
                }, 1500);
            }

            setTimeout(function(){
                setInterval(animation("start"), 20000);
            }, 20000);

            setTimeout(function(){
                for (var i = 0; i < frameList.length; i++) {
                    $(document.body).append($('<img class="invisible" src="{:C('IMG_PATH')}static/img/' + frameList[i] + '.png" />'));
                }
            }, 2000);
        });

        //
        var env = {};
        env.appid = "{$js_sign['appId']}";
        env.timestamp = "{$js_sign['timestamp']}";
        env.nonceStr = "{$js_sign['nonceStr']}";
        env.signature = "{$js_sign['signature']}";
        env.openid = "{$openid}";
        env.cardid = "{$cardid}";

        var shareTitle = [
                '现金红包在这，快点来摇！',
                '红包福利！抱抱堂摇摇乐',
                '现金红包，拿走不谢！',
                '抱抱堂爆米花新玩法，到店摇一摇，现金红包抢不停',
                '一大波红包正在靠近，快来试试手气',
                '天呐，居然有这么多现金红包'
        ];

        var share = {
            'title' : '抱抱堂-摇摇乐',
            'link' : '{$shareUrl}',
            'desc' : shareTitle[Math.floor(Math.random()*100 % shareTitle.length)],
            'imgUrl' : '{$user_info.avatar}'
        }

        wx.config({
            debug: false,
            appId: env.appid, // 必填，公众号的唯一标识
            timestamp: env.timestamp, // 必填，生成签名的时间戳，切记时间戳是整数型，别加引号
            nonceStr: env.nonceStr, // 必填，生成签名的随机串
            signature: env.signature, // 必填，签名，见附录1
            jsApiList: [
                'checkJsApi',
                'addCard',
                'chooseCard',
                'openCard',
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
//              'getLocation'
            ]
        });
        wx.ready(function () {
            enrolMenu();
        });

        function enrolMenu() {
            wx.onMenuShareTimeline({
                title: share.desc,
                link: share.link,
                imgUrl: share.imgUrl,
                trigger: function (res) {
                    //alert('用户点击分享到朋友圈');
                },
                success: function (res) {
                    $.post("{:U('Portal/OpenApi/tongji')}", { obj_id : 1}, function( data ) {
                    });
                    //alert('已分享');
                },
                cancel: function (res) {
                    //alert('已取消');
                },
                fail: function (res) {
                    //alert(JSON.stringify(res));
                }
            });
            //alert('已注册获取“分享到朋友圈”状态事件');

            wx.onMenuShareAppMessage({
                title: share.title,
                link: share.link,
                imgUrl: share.imgUrl,
                desc: share.desc, // 分享描述
                type: 'link', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function () {
                    // 用户确认分享后执行的回调函数
                    $.post("{:U('Portal/OpenApi/tongji')}", { obj_id : 2}, function( data ) {
                    });
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
        }
    })();

imgs = document.getElementsByTagName("img");
imgsnum = imgs.length;
for(imgi = 0 ;imgi < imgsnum;imgi++){
     if ((typeof(imgs[imgi].src) == 'undefined' || imgs[imgi].src =='') && imgs[imgi].getAttribute('thissrc') != null)
        imgs[imgi].src = imgs[imgi].getAttribute('thissrc');
}

</script>
</html>